﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Design.Serialization;
using System.IO;
using System.Web.UI.WebControls;
using System.Workflow.ComponentModel;
using System.ComponentModel;
using System.Workflow.ComponentModel.Serialization;
using ICalendar;

namespace ICalendarActivities
{
    [DesignerSerializer(typeof(ListSerializer), typeof(WorkflowMarkupSerializer))]
	public partial class SendEmailActivity: Activity
	{
		public SendEmailActivity()
		{
			InitializeComponent();
//            base.SetReadOnlyPropertyValue(AttendeesProperty, new List<Attendee>());
		}

        //public static DependencyProperty AttendeesProperty = DependencyProperty.Register("Attendees", typeof(List<Attendee>), typeof(SendEmail), new PropertyMetadata(DependencyPropertyOptions.Metadata | DependencyPropertyOptions.ReadOnly, new Attribute[] { new BrowsableAttribute(true), new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content) }));
        public static DependencyProperty AttendeesProperty = System.Workflow.ComponentModel.DependencyProperty.Register("Attendees", typeof(List<ICalendar.Parameter>), typeof(SendEmailActivity));

        //[Description("Attendees to the Calendar")]
        //[Browsable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]        
        //public List<Attendee> Attendees
        //{
        //    get
        //    {
        //        return (List<Attendee>)base.GetValue(AttendeesProperty);
        //    }
        //    //set
        //    //{
        //    //    base.SetValue(AttendeesProperty, new AttendeeCollection());
        //    //}
        //}

        [Browsable(true)]
        [RefreshProperties(RefreshProperties.All)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public List<ICalendar.Parameter> Attendees
        {
            get
            {
                return ((List<ICalendar.Parameter>)(base.GetValue(AttendeesProperty)));
            }
            set
            {
                base.SetValue(AttendeesProperty, value);
            }
        }

        //[Description("Carbon copy recipient")]
        //[Browsable(true)]
        //[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        //public string Path
        //{

        //    get
        //    {
        //        return Convert.ToString(base.GetValue(PathProperty));
        //    }
        //    set
        //    {
        //       base.SetValue(PathProperty, value);
        //    }

        //}



        //public string Text
        //{

        //    get
        //    {
        //        return Convert.ToString(base.GetValue(TextProperty));
        //    }

        //    set
        //    {
        //        base.SetValue(TextProperty, value);
        //    }

        //}

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {

            try
            {
                //File.WriteAllText(this.Path, this.Text);
                return ActivityExecutionStatus.Closed;
            }

            catch
            {
                return ActivityExecutionStatus.Faulting;
            }

        }



	}
}
